#include "frameworkcore.h"
#include "framework_global.h"

#define FW_CALL_INIT(name) do{\
   for(fw_init_fn_t *ptr = (fw_init_fn_t*)&__fw_init__start_##name##_export; \
       ptr < (fw_init_fn_t*)&__fw_init__end_##name##_export; \
       ptr++)  \
   {\
       (*ptr)();\
   }\
}while(0)

#define FW_REGION_DEF(name, start, end)\
    void __start_##name##_export(void){}\
    FW_INIT_EXPORT(__start_##name##_export, start);\
    void __end_##name##_export(void){}\
    FW_INIT_EXPORT(__end_##name##_export, end)

//自动注册占位
FW_REGION_DEF(board, 0, 1.end);
FW_REGION_DEF(device, 2, 3.end);
FW_REGION_DEF(app, 4, 5.end);

#ifdef  FW_FULL_ASSERT
void FW_AssertFailed(uint8_t *file, uint32_t line)
{
    while(1)
    {
        
    }
}
#endif 

void FW_Init()
{
    
}

void __FW_BoardAutoInit()
{
    FW_CALL_INIT(board);
}

void __FW_DeviceAutoInit()
{
    FW_CALL_INIT(device);
}

void __FW_AppAutoInit()
{
    FW_CALL_INIT(app);
}
